//右滑关闭
mui.init({
	swipeBack: true,
})
var currentwindow;
var counts = "";
window.onload = function() {
	mui.plusReady(function() {
		$("#all").html("");
		$("#all").html(
			'<a style="font-size:100px; color:#F27D48; display:block; text-align:center;" class="mui-icon mui-icon-search"></a><a class="mui-title" style="color:#808080; position: initial; margin: 0 auto; height:' +
			(window.screen.height - 200) + 'px">暂无数据</a>');
		plus.nativeUI.closeWaiting();

	})
}

var UserNO = localStorage.getItem("UserName");
//alert(UserNO);
function showinfo() {
	event.preventDefault(); // 阻止默认行为
	change2(1);
}

function openPosition(TradeNO, SourceOrderNO, SupplyName, WarehouseName) {



	mui.openWindow({
		url: 'WMS_RecGetUp.html',
		action: UserNO,
		extras: {
			TradeNO: TradeNO,
			SourceOrderNO: SourceOrderNO,
			SupplyName: SupplyName,
			WarehouseName: WarehouseName
		}
		// show: {
		// 	autoShow: false
		// }
	});


	// console.log("'" + urlorder + "'");

}



function change2(e) {

	pageno = e;
	var pageall;
	//$("#all").html("");//全部清空
	var html = "";
	var TradeNO = $("#TradeNO").val();
	var Creatime = $("#Creatime").val();

	console.log(Creatime);
	xccpost("JyhstWebASHX.ashx", {
		Action: "GetTradeRful",
		PageIndex: e,
		PageSize: 10,
		TradeNO: TradeNO,
		Creatime: Creatime
	}, function(data) {

		pageall = Math.ceil(parseInt(data.length) / 5) //向上取整    parseInt:转换为INT类型
		if (data.length != null && data.length > 0) {
			$("#all").html(""); ////全部清空
			for (var i = 0; i < data.length; i++) {
				$("#all").append('<li class="mui-table-view-cell" onclick="openPosition(' +
					"'" + data[i].TradeNO + "'," +
					"'" + data[i].SourceOrderNO + "'," +
					"'" + data[i].SupplyName + "'," +
					"'" + data[i].WarehouseName + "'" + ')"><p>' +
					'入库单号：' + data[i].TradeNO +
					'&nbsp;|&nbsp;收料单号: ' + data[i].SourceOrderNO +
					'&nbsp;|&nbsp;客户名称: ' + data[i].SupplyName +
					'&nbsp;|&nbsp;仓库名称：' + data[i].WarehouseName +
					'&nbsp;|&nbsp;制单日期：' + data[i].CreateTime +
					'</p></li>')

				if (e < 1) {
					e = 1;
					pageno = 1; //就等于第1页 ， 当前页为1
				}
				if (e > pageall) { //如果输入页大于最大页
					e = pageall;
					pageno = pageall; //输入页和当前页都=最大页
				}
				var pageContent = "";
				pageContent += '第<span id=\"a2\">' + pageno + '</span>/';
				pageContent += '<span id="a1">' + pageall + '</span>页';
				/*pageContent +='<span id="a3" >'+ye+'</span>';*/
				if (e > 1) { //页数大于1不能上一页
					pageContent += '<a href="#" onClick="change2(--pageno)" >上一页</a>';
				}
				if (e < pageall) { //页数小于不能上一页
					pageContent += '<a href="#" onClick="change2(++pageno)">下一页</a>';
				}
				if (pageno <= pageall) {
					$("#page").html(pageContent);
				}

			}

		} else {
			$("#all").html("");
			$("#all").html(
				'<a style="font-size:100px; color:#F27D48; display:block; text-align:center;" class="mui-icon mui-icon-search"></a><a class="mui-title" style="color:#808080; position: initial; margin: 0 auto; height:' +
				(window.screen.height - 200) + 'px">暂无数据</a>');
		}
	}, function(errr) {
		mui.toast("网络错误....");
	})



}